composite data types - a data type constructed using several of the basic data types available in a particular programming language
TYPE
StudentRecord
DECLARE name : STRING
DECLARE age : INTEGER
END TYPE
DECLARE Student : StudentRecord
Student.name <- "Smart Chen"
Student.age <- 16
a data structure containing several elements of the same data type
DECLARE numList : ARRAY[0:8] OF INTEGER
numList[3] <- 24
DECLARE sudoku : ARRAY[0:8,0:8] OF INTEGER
sudoku[0,0] <- 3
Pseudocode
x
DECLARE numList : ARRAY[1:8] OF INTEGER
DECLARE search : INTEGER
DECLARE i : INTEGER
DECLARE found : BOOLEAN
found <- FALSE
INPUT search
FOR i <- 1 to length
IF
numList[i] = search
THEN
OUTPUT “Found at:”, i
found <- TRUE
ENDIF
NEXT i
IF
found = FALSE
THEN
OUTPUT “Not found”
ENDIF
Python
l = [6, 3, 0, 5, 1, 2, 8, -1, 4]
search = int(input())
for i in range(len(l)):
if l[i] == search:
index = i
print(f"Found at: {index}")
break
else:
index = -1
print("Not found")
Pseudocode
x
DECLARE a : ARRAY[1:8] OF INTEGER
DECLARE swap : BOOLEAN
DECLARE i : INTEGER
DECLARE j : INTEGER
DECLARE temp : INTEGER
i <- 1
swap <- TRUE
WHILE i <= LENGTH(a)-1 AND swap:
swap = FALSE
FOR j <- 1 to LENGTH(a)-i-1:
IF
a[j] > a[j+1]
THEN
temp <- a[j]
a[j] <- a[j+1]
a[j+1] <- temp
swap <- TRUE
ENDIF
ENDWHILE
Python
xxxxxxxxxx
a = [5, 3, 7, 2, 1, 8, 4, 6]
for i in range(len(a)-1):
finished = 1
for j in range(len(a)-i-1):
if a[j] > a[j+1]:
a[j], a[j+1] = a[j+1], a[j]
finished = 0
if finished: break
3 modes of open files
xxxxxxxxxx
DECLARE firstLine : STRING
OPEN file.txt FOR READ
READFILE file.txt, firstLine
CLOSEFILE file.txt
OPEN file.txt FOR APPEND
WRITEFILE file.txt, "this is the second line"
CLOSEFILE file.txt
ADT: a collection of data and a set of operations on that data
a list containing several items operating on the last in, first out (LIFO) principle
a list containing several items operating on the first in, first out (FIFO) principle.
a list containing several items in which each item in the list points to the next item in the list.